package terminal.interfaces;

/**
 * Serial Port interface
 * @author P. Podwapinski
 */
public interface ISerialPort {
    
    /**
     * Opens a serial port with given name and baud rate
     * @param portName port name to open
     * @param baudRate desired baud rate
     * @return true if port has been opened
     */    
    boolean open( final String portName, final String baudRate );
    
    
    /**
     * If opened, closes the port and brings all the internal settings to their 
     * default values
     * @return true if port was successfuly closed
     */       
    boolean close();
 
    
    /**
     * Checks if the port is opened and operable
     * @return true if port is opened
     */    
    boolean isOpened();
    
    /**
     * Writes a single UNICODE character to the Serial Port.
     * Character will be converted to 8-bit value (byte).
     * @param character value to be printed
     * @return true if succeeded
     */
    boolean writeChar( char character );

    
    /**
     * Returns a serial port name used to create port
     * @return Serial Port Name or null if port not opened
     */    
    String getPortName();
    
    
    /**
     * Returns a String containing a Baud Rate used to configure the port
     * @return String containing BaudRate, 0 if port not opened
     */    
    String getBaudrate();    
}
